package com.huatao.wx.handler;

import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.ComponentScan;

import java.util.Map;

@ComponentScan
@Slf4j
public class SubscribeMsgHandler implements WcChatMsgHandler{
    @Override
    public WxChatMsgTypeEnum getMsgType() {
        return WxChatMsgTypeEnum.SUBSCRIBE;
    }

    @Override
    public String dealMsg(Map<String, String> msgMap) {
        log.info("触发用户点击事件");
        String fromUserName = msgMap.get("fromUserName");
        String toUserName = msgMap.get("toUserName");
        String subscribeContent = "感谢你的关注，我是Leo，欢迎一起来刷题练题";
        String content = "<xml>\n" +
        "  <ToUserName><![CDATA["+fromUserName+"]]></ToUserName>\n" +
        "  <FromUserName><![CDATA["+toUserName+"]]></FromUserName>\n" +
        "  <CreateTime>12345678</CreateTime>\n" +
        "  <MsgType><![CDATA[text]]></MsgType>\n" +
        "  <Content><![CDATA["+ subscribeContent +"]]></Content>\n" +
        "</xml>";
        return content;
    }
}
